package com.example.demo1.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * Description: 本类用于
 * Created by 白相宇 on 2019/12/27 9:30
 */
@Configuration
@EnableSwagger2
public class Swagger {
    @Bean
    public Docket docket(){
        return new  Docket(DocumentationType.SWAGGER_2).groupName("云")
                .apiInfo(apiInfo())
                //enable :是否启动swagger，false不启动，true启动
                // .enable(false)
                .select()
                /*RequestHandlerSelectors ：配置要扫描接口的方式
                 * basePackage() :扫描指定的包
                 * any() : 扫描全部
                 * none() : 不扫描
                 * withClassAnnotation() :扫描类上的注解，参数是一个注解的对象
                 * withMethodAnnotation() :扫描方法上的注解
                 */
                .apis(RequestHandlerSelectors.basePackage("com.example.demo1.controller"))
                //paths :过滤什么路径
//                .paths(PathSelectors.ant("com.example.demo1.controller/*"))
                .build()
                ;
    }

    private ApiInfo apiInfo(){
        //作者信息
        Contact DEFAULT_CONTACT = new Contact("白", "http://localhost:8080/", "123@qq.com");
        return new ApiInfo(
                "配置Swagger",
                "练习配置Swagger",
                "1.0",
                "urn:tos",
                DEFAULT_CONTACT,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }

    @Bean
    public Docket docket1(){
        return new  Docket(DocumentationType.SWAGGER_2).groupName("A");
    }
    @Bean
    public Docket docket2(){
        return new  Docket(DocumentationType.SWAGGER_2).groupName("B");
    }@Bean
    public Docket docket3(){
        return new  Docket(DocumentationType.SWAGGER_2).groupName("C");
    }


}
